home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / utilities / system / intuition / shadow / docs / shadowlibrarymethods.doc < prev    next >
Encoding:
Text File  |  1995-03-17  |  43.6 KB  |  941 lines

  1.                        Shadow.library  Documentation
  2.                             Library Version 4.6
  3.  
  4.                               By David Navas
  5.                          Updated:  09 Feb 1992
  6.  
  7.                       Copyright © 1992 by David Navas
  8.                             All Rights Reserved
  9.  
  10. Method definition for the following classes as defined in SHADOW 4.3:
  11.       DirectorClass
  12.       MetaClass
  13.       MetaCluster
  14.       PatcherClass
  15.       ProcessClass
  16.       RootClass
  17.       RootCluster
  18.  
  19. REVIEW
  20.  
  21.    Methods are handled by the 'class' of an object.  Classes are objects
  22.    whose 'classes' are referred to as 'metas'.  So the 'class' of a Class
  23.    object is a Meta.  The 'class' of a meta is the instance of itself.
  24.  
  25.    if this confuses you, you need to Read Introduction.doc first.  And
  26.    then re-read it.  And then refer to the Glossary.doc for the difference
  27.    between a Class and a class....
  28.  
  29.    Methods are implemented as strings, and the MethodTable is an array of
  30.    MethodHandlers that have been defined for a class of objects that are
  31.    managed by the object's class.  Similarly, 'attributes' are implemented
  32.    as strings.  Attributes contain the definition of the variables that
  33.    are stored in an object.  For instance, a BookClass might have an
  34.    attribute ATTR_NUMBERPAGES which would represent an integer inside
  35.    of a BookObject that contains the number of pages that that book had.
  36.  
  37.    In addition to Classes, SHADOW defines Clusters as the 'class' of
  38.    Composite Objects.  A Composite Object is sort of like a bag of objects.
  39.    When the composite is fully initialized (see: METHOD_META_INIT), it
  40.    contains a number of objects stored in a binary tree.  The attribute of
  41.    this binary tree is represented as ATTR_BAG.  Therefore, you can
  42.    get a pointer to the binary tree (which is what y0u need to pass to the
  43.    various binary tree manipulation functions) by calling:
  44.       bt = (AVLTREE *)FindAttribute(compositeObject, ATTR_BAG);
  45.    Or you can merely use the structure 'struct CoreComposite' and
  46.    de-reference directly off of that.
  47.  
  48.    Once the composite is initialized, you may add or remove as many of the
  49.    objects as you like.  Caution: if you remove an object, please remember
  50.    to send the removed object a METHOD_META_REMOVE method so that it can
  51.    be removed from it's class' instance tree.
  52.  
  53.  
  54. INHERITENCE
  55.  
  56.    Methods are inherited from a superclass, as are attributes.  The
  57.    following discussion will only explain the NEW methods and attributes
  58.    which a 'class' defines, or the methods which are subclassed by the
  59.    'class'.  Each 'class' inherits methods from its superclass by default.
  60.    Therefore, we will talk about classes in the order in which they appear
  61.    in the inheritence hierarchy.  The hierarchy is as follows:
  62.  
  63.                                  MetaClass
  64.                                      |
  65.                                      |
  66.                                 MetaCluster
  67.  
  68.  
  69.  
  70.  
  71.  
  72.                                  RootClass
  73.                         ________/    |    \__________
  74.                        |             |               |
  75.                   DirectorClass  PatcherClass  ProcessClass
  76.  
  77.  
  78.  
  79.  
  80.                                 RootCluster
  81.  
  82.  
  83. CLASS OVERVIEW:
  84.  
  85.    MetaClass and MetaCluster are the meta descriptiosn for Class and
  86.    Cluster.
  87.  
  88.    RootClass and RootCluster are the roots of the Class and Cluster
  89.    inheritence hiearchies  They do things like store the object into the
  90.    class' ATTR_OBJECTLIST (a watched binary tree), and they define the
  91.    Cluster as starting with an ATTR_BAG.
  92.  
  93.    DirectorClass is the class for director objects, usually referred to as
  94.    watchers.  SHADOW defines a type of variable called WatchedVariables.
  95.    Director objects are the objects responsible for actually watching
  96.    these WatchedVariables.  They provide Notification methods, and also
  97.    sport the ability to watch more than one variable at a time via the
  98.    ESTABLISH/TERMINATE method protocol.
  99.  
  100.    PatcherClass is the class for method patch objects.  Every method in
  101.    SHADOW can be patched -- this is SetFunction() done right!  Method
  102.    patches for a class are located in a watched list referred to as
  103.    ATTR_PATCHEDVERBS.  Patches have a priority (higher priority patches
  104.    get called before lower priority patches -- regular method is default
  105.    priority zero), can dynamically prevent subsequent patches of lower
  106.    priority from being called, and may only patch a single verb at a time,
  107.    unlike watchers.  Please Note!:  it is impossible to patch the DESTROY
  108.    method -- see RemoveAllPatches() for more details.
  109.  
  110.    ProcessClass (more accurately referred to as ThreadClass, because of
  111.    the way AmigaDOS treats Tasks/Processes) is the class for process
  112.    objects.  They attach themselves to your task->tc_UserData field,
  113.    SO DON'T MESS WITH THAT FIELD!  Process objects keep track of IPC
  114.    ports, the parent task pointer (-1 if no parent), the message for use
  115.    during synchronous communications, etc.   Each program that intends
  116.    to call methods, either actively via DoJazzMethod() or DJM(), or
  117.    passively via DropObject(), or possibly even via callbacks in the
  118.    FindAttribute() code, should call InitOOProgram().  Unfortunately, this
  119.    makes subclassing ProcessClass for your own process more or less
  120.    pointless.  However, because METHOD_META_SUB is actually a callback
  121.    method, it is safe to create a subclass of Process Class and then send
  122.    that class a METHOD_META_CREATE followed by a METHOD_PROC_ASSOCIATE as
  123.    documented leter in this file.  The attribute ATTR_JAZZPROCESS -must-
  124.    be located eight bytes from the start of the object, so please don't
  125.    define your own private process-class unless it is a subclass of
  126.    ProcessClass.
  127.  
  128.  
  129. METHOD CALLING CONVENTIONS
  130.  
  131.    All methods are called with at least four parameters.  The first is a
  132.    pointer to an IPCMessage structure.  If this parameter is non-NULL, it
  133.    means that the method was called with an asynchronous method, and the
  134.    passed IPCMessage is the message which was sent to the task.  The
  135.    name of this parameter is 'msg'.
  136.  
  137.    The second parameter is the object that the method was called on.
  138.    However, the term 'object' would be ambiguous, as the instance that
  139.    the method was called on may well be a class-object or a meta-object.
  140.    Nevertheless, in the code, the parameter is named 'object'.
  141.  
  142.    The third parameter is the class pointer, which is the pointer to
  143.    the class for which the method is defined (under the hierarchy of the
  144.    object->cob_class, of course).  The parameter's name in the code is
  145.    'class'.
  146.  
  147.    The last default parameter is the MethodID itself.  This is guaranteed
  148.    to be a pointer to the system string which stores the name of the
  149.    method.  This parameter is named 'MethodID'.
  150.  
  151.    All four of these parameters can be found in the METHOD_ARGS #define in
  152.    the include file: shadow/misc.h.
  153.  
  154.  
  155. SYSTEM CLASS DEFINITIONS
  156.  
  157.    METACLASS
  158.  
  159.       attributes:
  160.          ATTR_CORE         -- the minimal class variables, including the
  161.                                attribute and method table pointers
  162.          ATTR_PATCHEDVERBS -- watched list of method patches.
  163.          ATTR_OBJECTLIST   -- watched binary tree of meta's instances.
  164.                                Metas are kept on a special watched binary
  165.                                tree located in ShadowBase->sb_metaTree.
  166.                                Classes (as instances of MetaClass) are
  167.                                kept on this OBJECTLIST.  Note that even
  168.                                though Metas are, strictly, instances of
  169.                                themselves, they do not exist on their
  170.                                own OBJECTLIST tree.
  171.  
  172.       methods:
  173.          METHOD_META_CREATE
  174.             run as:
  175.                function in caller's process.
  176.             arguments:
  177.                none.
  178.  
  179.                NOTE: this function may NOT be called asynchronously!
  180.                Returns a pointer to an unitialized object.
  181.  
  182.             function:
  183.                Allocates an instance of a particular class.  IE:this is a
  184.                method which is sent to a Class, not its instances.
  185.                It creates an object, fills in the class field and any
  186.                default attribute values as specified in the class attribute
  187.                table, and returns the allocated object.
  188.  
  189.                Note that this object CANNOT have anything done to it UNTIL
  190.                it is sent a METHOD_META_INIT.  Among other things, the
  191.                useCount is zero.  DJM() correctly fails and frees the
  192.                object if a call to METHOD_META_INIT fails for any reason
  193.                (like the destination process has it's port closed, or
  194.                memory is running low).
  195.  
  196.                Memory is allocated :: (MEMF_PUBLIC | MEMF_CLEAR)
  197.  
  198.          METHOD_META_DESTROY
  199.             run as:
  200.                function in caller's process.
  201.             arguments:
  202.                none
  203.             function:
  204.                Invalidates the cache for any cache lines with the class
  205.                being destroyed.  See InvalidateCache() for details.
  206.                Frees any leftover watchers on the class
  207.                [FreeObjectWatchers()], destroys the method and attribute
  208.                tables, drops the class name and superclass references,
  209.                frees the object, drops its class, and hopefully handles
  210.                the case of transferring the pointer from the 'msg' field
  211.                to non-existence, just in case this method is called
  212.                asynchronously (which should NEVER happen).  This method
  213.                should ONLY be called by the internals of DropObject().
  214.                Please do not call it yourself.  This is the second half of
  215.                the two-level resource tracking.  This function is called
  216.                by DropObject() when the useCount of the object drops to
  217.                zero, implying no one has a pointer to the object.  As
  218.                evidenced by the FreeObjectWatchers() call, this may not be
  219.                entirely TRUE, but is nearly so....
  220.                Also calls RemoveAllPatches().
  221.  
  222.          METHOD_META_INIT
  223.             run as:
  224.                function in caller's process.
  225.             arguments:
  226.                JSTR -- name of the class to create
  227.                JOBJ -- optional superclass of the class to create.  This
  228.                         method is, however, sent to the class that is to
  229.                         be subclassed, so if this parameter is NULL, it
  230.                         defaults to the object which the method was sent
  231.                         to.
  232.                TAGL -- NULL terminated array of struct AttributeTag.  NULL
  233.                         is also valid.
  234.                TAGL -- NULL terminated array of struct MethodTag.  NULL is
  235.                         also valid.
  236.  
  237.                Returns a pointer to the initialized object.  NULL on
  238.                failure.  Object destroyed on failure....
  239.  
  240.             function:
  241.                As all good METHOD_META_INIT functions that can be called
  242.                by metas should, this method does not fill in the
  243.                superclass, attribute array, or method array, if the method
  244.                is called by a meta.  CreateMeta() should have already done
  245.                those things.
  246.  
  247.                Otherwise, this function fills in the superclass field,
  248.                creates the attribute array for the instance of the class,
  249.                fills in the instance size specification, and creates the
  250.                Method array.
  251.  
  252.                In both cases, it fills in the class name, binds all the
  253.                appropriate class watchers for its attributes  [Ed:
  254.                watched variables have both a list of watchers, and a
  255.                pointer to a second list of watcher.  SHADOW uses this
  256.                pointer to point to a list of watchers managed by the
  257.                class.  Under MetaClass and MetaCluster, these 'class'
  258.                watchers are copied into all subclasses.  See
  259.                BindSuperWatchers() for more details], and adds the object
  260.                into its class' ATTR_OBJECTLIST.  In the case of a meta,
  261.                this would be Shadow->sb_metaTree.  It also calls
  262.                BindWatchers() on the object which binds the second
  263.                watch-list pointer of all watched variables to the class'
  264.                attributes' SList.  See the struct Attribute definition and
  265.                the AutoDocs for BindWatchers().
  266.  
  267.          METHOD_META_REMOVE
  268.             run as:
  269.                function in caller's process.
  270.             arguments:
  271.                none
  272.             function:
  273.                Frees all class watchers associated with this class.  See
  274.                FreeClassWatchers() for further details.  Removes the
  275.                instance (in this method, the instance is a Class) from its
  276.                class' ATTR_OBJECTLIST.  If this is a Meta being removed,
  277.                the Meta is removed from ShadowBase->sb_metaTree instead.
  278.                This is the first of the two-level resource tracking done
  279.                on objects.  In addition, removal from this tree implies
  280.                that the system can no longer find your class/meta,
  281.                effectively removing it from the system.  It is not
  282.                destroyed, however, until no one has a pointer to it
  283.                (assuming they have used UseObject() and DropObject()
  284.                appropriately.  All self-references, either direct or
  285.                indirect, should be eliminated in this method.
  286.  
  287.          METHOD_META_SUB
  288.             run as:
  289.                function in caller's process.
  290.             arguments:
  291.                JSTR -- name of the class to create
  292.                JOBJ -- optional superclass of the class to create.  This
  293.                         method is, however, sent to the class that is to
  294.                         be subclassed, so if this parameter is NULL, it
  295.                         defaults to the object which the method was sent to.
  296.                TAGL -- NULL terminated array of struct AttributeTag.  NULL
  297.                         is also valid.
  298.                TAGL -- NULL terminated array of struct MethodTag.  NULL is
  299.                         also valid.
  300.             function:
  301.                If this method is sent to a meta (that is, if object ==
  302.                object->cob_class), then CreateMeta() is called with the
  303.                parameter list (minus the default msg pointer) sent to
  304.                CreateMeta() as the InitMeta structure.  Returns whatever
  305.                CreateMeta() does.
  306.  
  307.  
  308.                Otherwise it instantiates a meta (creating a Class Object)
  309.                and sends a METHOD_META_INIT to it, returning whatever the
  310.                INIT method returns.
  311.  
  312.  
  313.    METACLUSTER
  314.  
  315.       attributes:
  316.          ATTR_CLASSTABLE   -- struct ClusterClassTable, list of classes
  317.                                to create and INIT when composite INIT'd.
  318.  
  319.       methods:
  320.          METHOD_META_DESTROY
  321.             run as:
  322.                function in caller's process.
  323.             arguments:
  324.                none
  325.             function:
  326.                ATTR_CLASSTABLE is freed, and method sent to superclass.
  327.                'msg' variables should be updated as transferred as well....
  328.  
  329.          METHOD_META_INIT
  330.             run as:
  331.                function in caller's process.
  332.             arguments:
  333.                JSTR -- name of the class to create
  334.                JOBJ -- optional superclass of the class to create.  This
  335.                         method is, however, sent to the class that is to
  336.                         be subclassed, so if this parameter is NULL, it
  337.                         default to the object which the method was sent to.
  338.                TAGL -- NULL terminated array of struct AttributeTag.  NULL
  339.                         is also valid.
  340.                TAGL -- NULL terminated array of struct MethodTag.  NULL is
  341.                         also valid.
  342.                TAGL -- NULL terminated array of classes to fill in the
  343.                         ATTR_CLASSTABLE.  NULL is also valid.
  344.  
  345.                Returns a pointer to the initialized object.  NULL on
  346.                failure.  Object destroyed on failure....
  347.  
  348.             function:
  349.                As all good METHOD_META_INIT functions that can be called
  350.                by metas should, this method does not fill in the
  351.                superclass, attribute array, or method array, if the method
  352.                is called by a meta.  CreateMeta() should have already done
  353.                those things.
  354.  
  355.                Otherwise, this function fills in the superclass field,
  356.                creates the attribute array for the instance of the cluster,
  357.                fills in the instance size specification, and creates the
  358.                Method array.
  359.  
  360.                In both cases, it fills in the class name, binds all the
  361.                appropriate class watchers for its attributes  [Ed:
  362.                watched variables have both a list of watchers, and a
  363.                pointer to a second list of watcher.  SHADOW uses this
  364.                pointer to point to a list of watchers managed by the
  365.                class.  Under MetaClass and MetaCluster, these 'class'
  366.                watchers are copied into all subclasses.  See
  367.                BindSuperWatchers() for more details], adds the object
  368.                into its class' ATTR_OBJECTLIST (in the case of a meta,
  369.                this would be Shadow->sb_metaTree), and creates the class
  370.                array from the third tags list (ATTR_CLASSTABLE).  It also
  371.                calls BindWatchers() on the object which binds the second
  372.                watch-list pointer of all watched variables to the class'
  373.                attributes' SList.  See the struct Attribute definition and
  374.                the AutoDocs for BindWatchers().
  375.  
  376.          METHOD_META_SUB
  377.             run as:
  378.                function in caller's process.
  379.             arguments:
  380.                JSTR -- name of the class to create
  381.                JOBJ -- optional superclass of the class to create.  This
  382.                         method is, however, sent to the class that is to
  383.                         be subclassed, so if this parameter is NULL, it
  384.                         defaults to the object which the method was sent to.
  385.                TAGL -- NULL terminated array of struct AttributeTag.  NULL
  386.                         is also valid
  387.                TAGL -- NULL terminated array of struct MethodTag.  NULL is
  388.                         also valid.
  389.                TAGL -- NULL terminated array of classes to fill in
  390.                         ATTR_CLASSTABLE with.  NULL is also valid.
  391.  
  392.             function:
  393.                If this method is sent to a meta (that is, if object ==
  394.                object->cob_class), then CreateMeta() is called with the
  395.                parameter list (minus the default msg pointer) sent to
  396.                CreateMeta() as the InitMeta structure.  Returns whatever
  397.                CreateMeta() does.
  398.  
  399.  
  400.                Otherwise it instantiates a meta (creating a Class Object)
  401.                and sends a METHOD_META_INIT to it, returning whatever the
  402.                INIT method returns.
  403.  
  404.  
  405.    ROOTCLASS
  406.  
  407.       attributes:
  408.          none
  409.       methods:
  410.          METHOD_META_CREATE
  411.             see METHOD_META_CREATE in MetaClass.
  412.  
  413.          METHOD_META_DESTROY
  414.             run as:
  415.                function in caller's process.
  416.             arguments:
  417.                none
  418.             function:
  419.                Frees any leftover watchers on the object
  420.                [FreeObjectWatchers()], frees the object, and drops its
  421.                class.  Hopefully handles the case of transferring the
  422.                pointer from the 'msg' field to non-existence, just in case
  423.                this method is called asynchronously (which should NEVER
  424.                happen).  This method should ONLY be called by the
  425.                internals of DropObject().  Do not call it yourself.  This
  426.                is the second half of the two-level resource tracking.
  427.                This function is called by DropObject() when the usecount
  428.                of the object drops to zero, implying no one has a pointer
  429.                to the object.  As evidenced by the FreeObjectWatchers()
  430.                call, this may not be entirely TRUE, but is nearly so....
  431.  
  432.          METHOD_META_INIT
  433.             run as:
  434.                function in caller's process
  435.             arguments:
  436.                JSTR -- name of the object to create (optional).  If
  437.                         specified, object stored on ATTR_OBJECTLIST sorted
  438.                         by address of string, rather than address of
  439.                         itself.
  440.  
  441.                Returns a pointer to the initialized object.  NULL on
  442.                failure.
  443.             function:
  444.                Adds object to ATTR_OBJECTLIST of its class, either sorted
  445.                by the address of the passed string, or, if NULL string, by
  446.                its own address.  Note that these are AVL trees, so it's
  447.                still well balanced.
  448.  
  449.                It also calls BindWatchers() to bind all the watched
  450.                attributes of the object's second List to the class
  451.                attribute's watched list.  See BindWatchers() for more
  452.                details.
  453.  
  454.          METHOD_META_REMOVE
  455.             run as:
  456.                function in caller's process.
  457.             arguments:
  458.                JSTR -- optional string under which the object might have
  459.                         been stored (in the ATTR_OBJECTLIST tree). Iif the
  460.                         METHOD_META_INIT was called with a string as a
  461.                         parameter, then the METHOD_META_REMOVE better be,
  462.                         or it will fail to work properly.
  463.             function:
  464.                Removes the object from its class' ATTR_OBJECTLIST.
  465.  
  466.  
  467.    ROOTCLUSTER
  468.  
  469.       attributes:
  470.          ATTR_BAG -- binary tree which all objects are stored on.
  471.                      NOT watched!
  472.       methods:
  473.          METHOD_META_CREATE
  474.             see METHOD_META_CREATE in MetaClass
  475.  
  476.          METHOD_META_DESTROY
  477.             run as:
  478.                function in caller's process.
  479.             arguments:
  480.                none
  481.             function:
  482.                Frees any leftover watchers on the object
  483.                [FreeObjectWatchers()], frees the object, and drops its
  484.                class.  Hopefully handles the case of transferring the
  485.                pointer from the 'msg' field to non-existence, just in case
  486.                this method is called asynchronously (which should NEVER
  487.                happen).  This method should ONLY be called by the
  488.                internals of DropObject().  do not call it yourself.  This
  489.                is the second half of the two-level resource tracking.
  490.                This function is called by DropObject() when the usecount
  491.                of the object drops to zero, implying no one has a pointer
  492.                to the object.  As evidenced by the FreeObjectWatchers()
  493.                call, this may not be entirely TRUE, but is nearly so....
  494.  
  495.                Also, removes all the objects on the composite's
  496.                ATTR_BAG, and sends a METHOD_META_REMOVE to all of those
  497.                removed objects.
  498.  
  499.          METHOD_META_INIT
  500.             run as:
  501.                function in caller's process
  502.             arguments:
  503.                JSTR -- name of the object to create (optional).  If
  504.                         specified, object stored on ATTR_OBJECTLIST sorted
  505.                         by address of string, rather than address of
  506.                         itself.
  507.  
  508.                Returns a pointer to the initialized object.  NULL on
  509.                failure.
  510.  
  511.             function:
  512.                Adds object to ATTR_OBJECTLIST of its class, either sorted
  513.                by the address of the passed string, or, if NULL string, by
  514.                its own address.  Note that these are AVL trees, so it's
  515.                still well balanced.
  516.  
  517.                It also calls BindWatchers() to bind all the watched
  518.                attributes of the object's second List to the class
  519.                attribute's watched list.  See BindWatchers() for more
  520.                details.
  521.  
  522.                Additionally, CREATEs and INITs (without arguments) all
  523.                objects whose classes are on the ATTR_CLASSTABLEof the
  524.                object's class.  Objects are stored on the ATTR_BAG's
  525.                binary tree under the name of the class.
  526.  
  527.          METHOD_META_REMOVE
  528.             run as:
  529.                function in caller's process.
  530.             arguments:
  531.                JSTR -- optional string under which the object might have
  532.                         been stored (in the ATTR_OBJECTLIST tree).  If the
  533.                         METHOD_META_INIT was called with a string as a
  534.                         parameter, then the METHOD_META_REMOVE better be,
  535.                         or it will fail to work properly.
  536.             function:
  537.                Removes the object from its class' ATTR_OBJECTLIST.
  538.  
  539.  
  540.    DIRECTORCLASS
  541.       attributes:
  542.          ATTR_MANAGER  -- struct ManagementNode.  The place where useful
  543.                            information about the director is stored.  For
  544.                            instance, information managing the conditions
  545.                            under which notification is sent, and to whom
  546.                            it is sent.
  547.          ATTR_DIRECTOR -- a WatchedList.  It is a list of all the
  548.                            established connections that have been made,
  549.                            in short, a list of all objects this Director
  550.                            is watching.  Interestingly, you can get
  551.                            notification of when the notification lists
  552.                            change.  And, of course, you can even have a
  553.                            class watcher watch everything at once!
  554.       methods:
  555.          METHOD_DIRECTOR_ESTABLISH
  556.             run as:
  557.                function in caller's process.
  558.             arguments:
  559.                APTR -- the attribute of the object to watch, or a pointer
  560.                         to the actual watchedVariable, if no object is
  561.                         specified.  This implies that this method CANNOT
  562.                         be safely called ASYNCronously
  563.                JOBJ -- the object in which the WatchedVariable is.  If
  564.                         this parameter is NULL, the method assumes that
  565.                         the APTR is a pointer to the WatchedVariable, and
  566.                         not the name of the attribute.
  567.                long -- priority of the watcher.
  568.  
  569.                Returns a handle to the connection.  You should either
  570.                DropObject() the handle, or keep it to pass to the
  571.                TERMINATE method, after which you should DropObject() it....
  572.  
  573.             function:
  574.                Establishes a connection, and adds that connection to the
  575.                ATTR_DIRECTOR list of connections.  Uses either
  576.                AddClassWatcher() or AddWatcherNode(), depending on the
  577.                type of Watcher this director-object is.  Please see the
  578.                AutoDocs for more information on these functions.
  579.  
  580.                The Watcher may either be a SHADOW_OBJECT watcher or a
  581.                SHADOW_CLASS watcher.  This is specified in the flags
  582.                argument to the METHOD_META_INIT.
  583.  
  584.             METHOD_DIRECTOR_TERMINATE
  585.                run as:
  586.                   function in caller's process.
  587.                arguments:
  588.                   JOBJ -- either the handle as returned by the ESTABLISH
  589.                            method, or a pointer to the object from which a
  590.                            watcher should be removed.  The latter case
  591.                            should be restricted to the
  592.                            Free[Object|Class]Watchers() functions.  Mostly
  593.                            because you are not guaranteed which handle of
  594.                            the watcher is removed.  For instance, if one
  595.                            watcher is watching more than one watched
  596.                            variable of a single object, then calling
  597.                            TERMINATE with the object being watched may
  598.                            release the watcher from any of those watched
  599.                            variables.
  600.                   long -- flags dictating whether this is a handle, or
  601.                            the object being watched, not specifying
  602.                            this parameter defaults to the type 'handle'
  603.                            (0), the other case is SHADOW_SORT -- value 1.
  604.                function:
  605.                   If flags are NULL, then simply removes the connection
  606.                   that that handle symbolizes.  If this is the last
  607.                   connection, and if the AUTOREMOVE flag was specified in
  608.                   the INIT call, then the Director is Remove()'d from the
  609.                   system.
  610.  
  611.                   Otherwise, if SHADOW_SORT is specified, the first handle
  612.                   on the list that is stored as being authorized by the
  613.                   passed object is terminated.
  614.  
  615.                   Uses RemoveClassWatcher() or RemoveWatcherNode()
  616.                   internally to remove the watcher from the watching-list.
  617.                   Please see the AutoDocs for more information on thse
  618.                   functions.
  619.  
  620.          METHOD_META_DESTROY
  621.             run as:
  622.                function in caller's process.
  623.             arguments:
  624.                none
  625.             function:
  626.                Name is Drop()'d from the ATTR_MANAGER node->mnn_name field.
  627.                If W_SECOND was specified during the METHOD_META_INIT, the
  628.                node->mnn_value is Drop()'d as well.  The superclass is
  629.                called, and the msg's object is transferred out of the
  630.                message, allowing for ASYNC methods to be sent to this object.
  631.  
  632.          METHOD_META_INIT
  633.             run as:
  634.                function in caller's process.
  635.             arguments:
  636.                JSTR -- the name of the object.
  637.                JOBJ -- object to send the notification method to.
  638.                JSTR -- the notification method.
  639.                long -- various flags controlling the type of watcher
  640.                         (object or class), the function of the
  641.                         notification, etc.
  642.                long -- optional value for the W_SECOND or W_MATCH_FIRST
  643.                         flags.  If W_SECOND is specified in the flags
  644.                         field, then this method cannot be called
  645.                         asynchronously, because this would be a pointer
  646.                         to a string....
  647.  
  648.                returns the initialized object, or NULL on failure.
  649.  
  650.             function:
  651.                As with all INIT functions, if the object is not
  652.                successfully INIT'd, the object is UseObject()'d and
  653.                DropObject()'d, resulting in a call to the
  654.                METHOD_META_DESTROY function.  Usually, the party
  655.                interested in receiving notification is UseObject()'d
  656.                and stored in the ATTR_MANAGER's node->mnn_method and
  657.                node->mnn_object.  The name is used and put into the
  658.                structure at node->mnn_name.  If  W_SECOND is specified
  659.                in the flags field, the optional value is treated as a
  660.                string.  In addition, this function parcels the long
  661.                flags value into its pieces.  The bottom 16 bits
  662.                become the instrument that controls when the Director
  663.                sends out its notification.  The next eight bits has only
  664.                one flag allocated that distinguish between SHADOW_OBJECT
  665.                and SHADOW_CLASS types of Directors.  (One watches a
  666.                particular object, the other watches all objects in a
  667.                class.)  The last eight bits control the working of the
  668.                internal resource tracking.  One bit is the
  669.                SHADOW_AUTOREMOVE.  When specified, the last connection
  670.                TERMINATion causes a METHOD_META_REMOVE to be sent to
  671.                itself.  The other bit is the SHADOW_AUTOBREAK flag.  When
  672.                it is specified, the REMOVE method automatically TERMINATEs
  673.                all connections.  Unless you do something very bizarre,
  674.                you should specify both bits.  An internal bit
  675.                (SHADOW_REMOVED) prevents an infinite recursion when both
  676.                bits are specified.
  677.  
  678.                You can control the notification so that it occurs only on
  679.                specific types of events.  This is controlled by the first
  680.                16 bits of the 'flags' parameter.  The W_* flags which
  681.                control the notification restriction are specified in the
  682.                method below.
  683.  
  684.          METHOD_META_NOTIFY
  685.             run as:
  686.                function in caller's process.
  687.             arguments:
  688.                long -- flags specifying what changed.
  689.                APTR -- a pointer to the WatchedVariable that caused the
  690.                         notification.  Note: this pointer will NOT be
  691.                         valid if sent ASYNC!  This implies that the method
  692.                         to which notification is sent might also inherit
  693.                         nonsense in this value, so don't do anything
  694.                         brash with the NOTIFY method!
  695.                APTR -- the new node/value of the WatchedVariable.  Once
  696.                         again, ASYNC causes nightmares.
  697.                JSTR -- the name of the new node, if specified.
  698.             function:
  699.                If this Director is interested in the particular piece of
  700.                information being broadcast, then notification is sent out.
  701.  
  702.                The following are the flags that effect this control.
  703.                These are the flags in the lower 16bits of the flags field
  704.                sent to the INIT function.
  705.  
  706.                   /*
  707.                    * Match either.
  708.                    */
  709.                   #define W_CHANGE_ZERO      1
  710.                   #define W_CHANGE_NON_ZERO  2
  711.                   #define W_CHANGE_VALUE     3
  712.  
  713.                   /*
  714.                    * Match exactly
  715.                    */
  716.                   #define W_NODE             4
  717.                   #define W_WATCH_CHANGE     8
  718.                   #define W_REMOVE           16
  719.                   #define W_INSERT           32
  720.  
  721.                   /*
  722.                    * Control matching.
  723.                    */
  724.                   #define W_MATCH            64
  725.                   #define W_MATCH_VALUE      W_MATCH
  726.                   #define W_SECOND           128
  727.  
  728.                   #define W_MATCH_FIRST      W_MATCH
  729.                   #define W_MATCH_SECOND     (W_SECOND | W_MATCH)
  730.  
  731.                   #define W_INSERT_NODE      (W_NODE | W_INSERT)
  732.                   #define W_REMOVE_NODE      (W_NODE | W_REMOVE)
  733.  
  734.                   #define W_INSERT_WATCHER   (W_WATCH_CHANGE | W_INSERT)
  735.                     /* Not valid during... */
  736.                   #define W_REMOVE_WATCHER   (W_WATCH_CHANGE | W_REMOVE)
  737.                     /* ... INIT[]/DESTROY[]  */
  738.  
  739.                The first three flags apply only to non-(list/tree)
  740.                variables.  IE: the simple longword type of watched
  741.                variable -- the WatchedValue.  W_CHANGE_ZERO is for when
  742.                the variable changes to a zero, W_CHANGE_NON_ZERO is for
  743.                when a variable changes to a non-zero, and W_CHANGE_VALUE
  744.                is for when either happens.  Note that the value may have
  745.                already been zero or non-zero.
  746.  
  747.                W_NODE is for any addition or removal of nodes from lists or
  748.                trees.  W_WATCH_CHANGE sends notification out when a watcher
  749.                is added.  A watcher can get notification when it adds
  750.                itself, but not when it removes itself -- sorry, you'll have
  751.                to use two watchers for that....  W_REMOVE and W_INSERT
  752.                control whether you want notification when something is
  753.                added or removed to/from the list/tree.
  754.  
  755.                W_MATCH is used for a simple matching capability.  You can
  756.                watch for a particular object to be removed from the tree,
  757.                or added to the tree, or whatever....
  758.  
  759.                W_MATCH_FIRST uses the value sent to the INIT function as
  760.                the value of, either:
  761.                   (a) the value that the WatchedVariable should take on.
  762.                   (b)the address of the object added to a list/tree.
  763.                 depending on the type of WatchedVariable.
  764.  
  765.                W_MATCH_SECOND uses the value sent to the INIT function
  766.                as the address of a string which would be the name under
  767.                which the node is added to the list/tree.
  768.  
  769.             METHOD_META_REMOVE
  770.                run as:
  771.                   function in caller's process.
  772.                arguments:
  773.                   none
  774.                function:
  775.                   If the Director had its SHADOW_AUTOBREAK specified, all
  776.                   connections are TERMINATEd.  The notification destination
  777.                   object and method are Drop()'d, cleared, and the Method
  778.                   is sent to the superclass.
  779.  
  780.  
  781.    PATCHERCLASS
  782.       attributes:
  783.          ATTR_METHODHANDLER -- must be at offset 8!  Contains a struct
  784.                                 MethodHandler followed by a class pointer
  785.                                 which indicates the class that was
  786.                                 patched.
  787.       method:
  788.          METHOD_META_DESTROY
  789.             run as:
  790.                function in caller's prcoess.
  791.             arguments:
  792.                none
  793.             function:
  794.                Drop()s the procObject, defnObject and MethodID of the
  795.                patch.  Calls the superclass, then transfers the object
  796.                from the msg so that it will work properly when/if called
  797.                asynchronously.
  798.  
  799.          METHOD_META_REMOVE
  800.             run as:
  801.                function in caller's process.
  802.             arguments:
  803.                none
  804.             function:
  805.                Patch is removed from the ATTR_PATCHEDVERBS list of the
  806.                class that this object is patching.  Superclass is then
  807.                called.
  808.  
  809.          METHOD_META_INIT
  810.             run as:
  811.                function in caller's process.
  812.             arguments:
  813.                APTR -- A MethodTag.  This does NOT cause problems for
  814.                         ASYNC methods....
  815.                JOBJ -- class to patch, or an object of that class, in
  816.                         which case, unless the object has an
  817.                         ATTR_PATCHEDVERBS attribute, the class, not the
  818.                         object, is patched.
  819.  
  820.                returns the initialized object, or NULL on failure.
  821.  
  822.             function:
  823.                As with all INIT functions, if the object is not
  824.                successfully INIT'd, the object is UseObject()'d
  825.                and DropObject()'d, resulting in a call to the
  826.                METHOD_META_DESTROY function.
  827.  
  828.                Usually, the method to be patched is found (failure to
  829.                find the method in the class requested causes the patch
  830.                to fail -- DOES NOT CHECK superclasses!), procObject and
  831.                defnObject in the MethodTag fields are Use()'d and put
  832.                into the ATTR_METHODHANDLER.  MethodID is also Use()'d.
  833.                In addition, all other MethodTag information is copied into
  834.                the MethodHandler structure.  Class information is saved in
  835.                the patched-class field -- this is NOT Use()'d!  Patch is
  836.                inserted, and method is sent to the superclass.
  837.  
  838.  
  839.    PROCESSCLASS
  840.       attributes:
  841.          ATTR_JAZZPROCESS   -- must be at offset 8!  Contains a struct
  842.                                 JazzProcess.
  843.          ATTR_RESOURCETREE  -- Watched binary tree that you can store
  844.                                 your resources on.
  845.          ATTR_RESOURCESTACK -- Watched list that you can store last
  846.                                 minute removal resources.  Freed only
  847.                                 during RemoveThread()
  848.       method:
  849.          METHOD_META_DESTROY
  850.             run as:
  851.                function in caller's process.
  852.             arguments:
  853.                none
  854.             function:
  855.                ATTR_RESOURCETREE is freed.
  856.  
  857.                ATTR_JAZZPROCESS' parent is NULLed.  If there is an
  858.                associated task, the task is Signalled with a ^C.  THAT
  859.                task should receive the ^C, check if parent is NULL,
  860.                and call RemoveThread() -- this function calls the
  861.                METHOD_META_DESTROY for the superclass of PROCESSCLASS
  862.                (ROOTCLASS, specifically), and then the task should quit.
  863.  
  864.                If there is no associated task, the superclass is called
  865.                directly.
  866.  
  867.          METHOD_META_REMOVE
  868.             run as:
  869.                function in caller's process.
  870.             arguments:
  871.                none
  872.             function:
  873.                Sent to superclass with the process' name -- found in
  874.                ATTR_JAZZPROCESS structure.
  875.                Also removes all resources stored in the ATTR_RESOURCETREE
  876.                 (but NOT those in the ATTR_RESOURCESTACK).
  877.  
  878.          METHOD_META_INIT
  879.             run as:
  880.                function in caller's process.
  881.             arguments:
  882.                JSTR -- name of the process to create.
  883.                FUNC -- the function to start the thread with.
  884.                         Defaults to defaultThreadStart internally in
  885.                         library.  You will need to check out
  886.                         WaitThread(), InitThread(), and the example
  887.                         in gui.c for your own FUNC.
  888.                SEMF -- an optional semaphore to own shared by the started
  889.                         process.  Semaphore is Release()'d when task exits.
  890.                TAGL -- a NULL terminated array of struct TagItem to send to
  891.                         the CreateNewProc call.  If the INIT fails AFTER
  892.                         the process is created, the tags' ti_Tag are set
  893.                         to TAG_IGNORE, so you don't have to free the
  894.                         resources that might be in the TAGL if the process
  895.                         fails to be created.  (In fact, the ti_Tags are
  896.                         set to TAG_IGNORE even if the process successfully
  897.                         opens.)
  898.  
  899.                returns the initialized object, or NULL on failure.
  900.  
  901.             function:
  902.                As with all INIT functions, if the object is not
  903.                successfully INITed, the object is UseObject()'d
  904.                and DropObject()'d, resulting in a call to the
  905.                METHOD_META_DESTROY function.
  906.  
  907.                Method sent to superclass.
  908.  
  909.                Semaphore Obtain()'d shared, process is created, and various
  910.                magic done to ensure a safe startup between processes.
  911.  
  912.                Will set all ti_Tag elements to TAG_IGNORE if process is
  913.                successfully started, even if process subsequently shuts
  914.                down due to a startup error.  This allows you to free
  915.                resources correctly (hopefully) when process' fail to start
  916.                properly, independent upon whether it was the
  917.                CreateNewProc() call that failed, or something else....
  918.  
  919.          METHOD_PROC_ASSOCIATE
  920.             run as:
  921.                function in caller's process.
  922.             arguments:
  923.                JSTR -- name of the current process.  Defaults to
  924.                         FindTask(NULL)->tc_node.ln_Name
  925.                TASK -- pointer to the task.  Defaults to
  926.                         FindTask(NULL).  Needs to be run in the
  927.                         that task's frame anyway, because Signals
  928.                         for message ports are allocated....
  929.  
  930.                returns object  which should NOT be DROP()'d!  This is
  931.                handled by the RemoveCurrentProgram() call.  This method
  932.                is usually called by the InitOOProgram() call.
  933.  
  934.             function:
  935.                Creates a SHADOW process object for a task that already
  936.                exists.  Stores it into task->tc_UserData, and then the
  937.                jp_parent field of the ATTR_JAZZPROCESS attribute is set
  938.                to -1.  Creates ports and synchronous messages for this
  939.                process.  Usually done by InitThread() during thread
  940.                startup....
  941.